package com.clz.appdesign.audio_video;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import java.io.File;

/**
 * @author chenliangzhi
 * @date 2018/8/6
 * @describe
 */

public class CustomImageView extends View {
    Paint mPaint = new Paint();
    Bitmap mBitmap = null;

    public CustomImageView(Context context) {
        this(context, null);
    }

    public CustomImageView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CustomImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mBitmap = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + File.separator + "Download" + File.separator + "reba.jpg");
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (mBitmap!=null){
            canvas.drawBitmap(mBitmap,0,0,mPaint);
        }
    }
}
